﻿using DialogHostAvalonia;
using MyTodo.Extensions;
using MyTodo.Views;
using Prism.Commands;
using Prism.DryIoc.Properties;
using Prism.Ioc;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyTodo.ViewModels
{
    public class SidebarViewModel : NavigationViewModel
    {
        private const int Collapsed = 50; //侧边栏收起的宽度
        private const int Expanded = 120; //侧边栏展开的宽度

        private readonly IRegionNavigationJournal _journal;
        private readonly IRegionManager _regionManager;
        private int _flyoutWidth;

        public SidebarViewModel(IContainerProvider container) : base(container)
        {
            Title = "菜单导航";
            FlyoutWidth = Expanded;
            this._regionManager = container.Resolve<IRegionManager>();
        }

        public DelegateCommand CmdIndex => new(() =>
        {
            //// _journal.Clear();
            _regionManager.RequestNavigate(PrismManager.MainViewRegionName, nameof(IndexView));
        });

        public DelegateCommand CmdTodo => new(() =>
        {
            //// _journal.Clear();
            _regionManager.RequestNavigate(PrismManager.MainViewRegionName, nameof(ToDoView));
        });



        public DelegateCommand CmdMemo => new(() =>
        {
            //// _journal.Clear();
            _regionManager.RequestNavigate(PrismManager.MainViewRegionName, nameof(MemoView));
        });


        public DelegateCommand CmdOther => new(() =>
        {
            //// _journal.Clear();
            //_regionManager.RequestNavigate(PrismManager.MainViewRegionName, nameof(ProgressView));
            
        });


        public DelegateCommand CmdFlyoutMenu => new(() =>
        {
            var isExpanded = FlyoutWidth == Expanded;
            FlyoutWidth = isExpanded ? Collapsed : Expanded;
        });

        public DelegateCommand CmdSettings => new(() => _regionManager.RequestNavigate(PrismManager.MainViewRegionName, nameof(SettingsView)));

        public int FlyoutWidth
        {
            get => _flyoutWidth;
            set => SetProperty(ref _flyoutWidth, value);
        }
        public string Title
        {
            get; set;
        }
    }
}
